<template>
  <div style="height: 100%;overflow:hidden">
    <x-header :left-options="{preventGoBack:true,backText: ''}" @on-click-back="backhome">安全检查单查看-离线</x-header>
    <div class="main-container" style="height:93%">
      <!-- <div id="map"></div> -->
      <v-touch v-on:swiperight="onSwipeRight" :swipe-options="{direction: 'horizontal'}">
        <div style="margin-bottom: 30px;">
          <group>
            <cell title="项目部" v-model="proDept"></cell>
            <cell title="工程项目" v-model="pro">
              <!-- <span>{{pro}}</span>  -->
            </cell>
            <cell v-model="checkDate" title="检查日期"></cell>
            <cell v-model="isReply" title="是否回复"></cell>
            <cell title="类别" v-model="FATHERCLASS"></cell>
            <cell title="检查项目" v-model="CHECKPRO"></cell>
            <!-- <cell title="检查项"  v-model="CHECKITEMS"></cell> -->
            <x-textarea title="检查项" v-model="CHECKITEMS" readonly></x-textarea>
          </group>
          <group title="描述">
            <x-textarea placeholder="请输入一段描述" v-model="DESCRIPTION" readonly></x-textarea>
          </group>
          <group title="检查图片">
            <div
              v-for="(item,index) in imgList"
              :key="index"
              style="display:flex;flex-direction: row"
              v-viewer="{toolbar: false, navbar: false}"
            >
              <img :src="item" style="width:60px;height:60px" />
            </div>

            <!-- <picture-upload :fieldToken='ATTACHMENTS'
                            :pageToken='ATTACHMENTS'
                            :value='ATTACHMENTS'
            :readonly='true'></picture-upload>-->
          </group>
          <group>
            <cell title="填写人" v-model="name"></cell>
            <cell title="联系电话" v-model="phone"></cell>
            <cell title="填写部门" v-model="dept"></cell>
            <cell title="填写时间" v-model="inputDate"></cell>
          </group>
          <group style="padding:0 10px 0 10px">
            <flexbox style="margin-top:20pt">
              <flexbox-item>
                <x-button type="warn" @click.native="deleteRecode">删除</x-button>
              </flexbox-item>
              <flexbox-item>
                <x-button @click.native="saveInspectionInfo">上传</x-button>
              </flexbox-item>
            </flexbox>
            <Toast :value="toastValue" :is-show-mask="true" text="保存成功" @on-hide="saveSuccess"></Toast>
            <Toast
              :value="toastValueErr"
              :is-show-mask="true"
              :text="err"
              @on-hide="saveErr"
              type="cancel"
              width="200px"
            ></Toast>
          </group>
        </div>
      </v-touch>
    </div>
  </div>
</template>
 
<script>
import "viewerjs/dist/viewer.css";
import Viewer from "v-viewer";
import Vue from "vue";
Vue.use(Viewer, {
  defaultOptions: {
    zIndex: 9999
  }
});
import * as L from "leaflet";
//Vue.L = Vue.prototype.$L = L
import {
  Group,
  Cell,
  XButton,
  Box,
  GroupTitle,
  Flexbox,
  FlexboxItem,
  Divider,
  Calendar,
  PopupPicker,
  Toast,
  Loading
} from "vux";
// import { TIMEOUT } from 'dns';
var map = null;
var marker = null;
export default {
  components: {
    XButton,
    Box,
    GroupTitle,
    Group,
    Flexbox,
    FlexboxItem,
    Divider,
    Group,
    Cell,
    Calendar,
    PopupPicker,
    Toast,
    Loading
  },
  name: "offlineInspDetail ",
  data() {
    return {
      //   msg: 'Welcome to Your Vue.js App',
      proDept: this.$route.query.pname,
      pro: this.$route.query.pro,
      proId: this.$route.query.proId,
      GUID: this.$route.query.GUID,
      centerPosition: this.$route.query.site,
      site: this.$route.query.site,
      FATHERCLASS: "",
      CHECKPRO: "",
      CHECKITEMS: "",
      name: "",
      phone: "",
      dept: "",
      DESCRIPTION: "",
      pageToken: "",
      fieldToken: "",
      buttonid: "",
      // map:"",
      checkDate: "",
      name: "",
      phone: "",
      dept: "",
      inputDate: "",
      ATTACHMENTS: "",
      fileNameItem: [],
      offlineUrl: [],
      toastValueErr: false,
      toastValue: false,
      data: [],
      imgList: this.$store.state.offlineflieurl, //本地图片存储路径
      successFlag:0,
      isReply:"",
    };
  },
  methods: {
    saveSuccess() {
      this.backhome();
    },
    saveErr() {
      this.toastValueErr = false;
    },
    deleteRecode() {
      const _this = this;
      this.$vux.confirm.show({
            // 组件除show外的属性
            title: "提示",
            content: "确认删除？",
            onCancel() {
            },
            onConfirm() {
              _this.$store.state.SQLiteDB.transaction(tx => {
                tx.executeSql(
                  'DELETE FROM PMHSE_INSPECTION WHERE GUID = "' + _this.GUID + '"'
                );
              });
              _this.backhome();
            }
      });
    },
    //上传文件
    upload(fileURL, guid) {
      console.log("upload:" + fileURL);
      var success = r => {
        //上传成功
        console.log("传上成功");
        console.log("rrrrrrr", r);

        this.imgList.map(item => {
          if (true) {
            // if (this.belongSubSys != '') {
            item.fileOldName = JSON.parse(r.response)[0].name;
            item.fileId = JSON.parse(r.response)[0].id;
            item.fieldToken = JSON.parse(r.response)[0].fieldToken;
            item.size = JSON.parse(r.response)[0].size;
            // } else if (this.server != '') {
            // item.fileId = JSON.parse(r.response).fileId // moaapi/feedback 接口
            // }
          }
        });
        this.successFlag++;
        if(this.successFlag == this.offlineUrl.length){
          var params = {
            _method: "formService.saveFormData",
            requestEventData: {
              eventType: "formSubmitEvent",
              formType: 1,
              bizObjId: "PMHSE_INSPECTION",
              formId: "PMHSE_INSPECTION_ADD",
              buttonId: this.guid()
            },
            _OBJ_NAME_: "PMHSE_INSPECTION",
            _FORM_ID_: "PMHSE_INSPECTION_ADD",
            useType: "add",
            pageToken: this.pageToken,
            formData: {
              objName: "PMHSE_INSPECTION",
              pks: ["GUID"],
              data: [
                {
                  rowData: [
                    {
                      DataTarget: "GUID",
                      Value: "",
                      OriginalValue: null,
                      PK: true,
                      DataType: "String"
                    },
                    {
                      DataTarget: "RESTATE",
                      Value: "0",
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "PRODEPT",
                      Value: this.data.PRODEPT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CONSTRUCTPRO",
                      Value: this.data.CONSTRUCTPRO,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "PROJECTID",
                      Value: this.data.PROJECTID,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SYSPRJID",
                      Value: this.data.SYSPRJID,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CENTERPOSITION",
                      Value: this.data.CENTERPOSITION,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKDATE",
                      Value: this.data.CHECKDATE,
                      OriginalValue: null,
                      PK: false,
                      DataType: "DATE"
                    },
                    {
                      DataTarget: "CHECKMONTH",
                      Value: this.data.CHECKMONTH,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKYEAR",
                      Value: this.data.CHECKYEAR,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKMY",
                      Value: this.data.CHECKMY,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "FATHERCLASS_TEXT",
                      Value: this.data.FATHERCLASS_TEXT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "FATHERCLASS",
                      Value: this.data.FATHERCLASS,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKPRO_TEXT",
                      Value: this.data.CHECKPRO_TEXT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKPRO",
                      Value: this.data.CHECKPRO,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKQUARTER",
                      Value: this.data.CHECKQUARTER,
                      OriginalValue: null,
                      PK: false,
                      DataType: "int"
                    },
                    {
                      DataTarget: "CHECKITEMS_TEXT",
                      Value: this.data.CHECKITEMS_TEXT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKITEMS",
                      Value: this.data.CHECKITEMS,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SECURITYLEVEL",
                      Value: "一般",
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHILDCLASS",
                      Value: this.data.CHILDCLASS,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "IMPORTANCE",
                      Value: this.data.IMPORTANCE,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "WEIGHT",
                      Value: this.data.WEIGHT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SYSTODAY",
                      Value: this.data.SYSTODAY,
                      OriginalValue: null,
                      PK: false,
                      DataType: "TimeStamp"
                    },
                    {
                      DataTarget: "DESCRIPTION",
                      Value: this.data.DESCRIPTION,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "HIDDENNUM",
                      Value: 0,
                      OriginalValue: null,
                      PK: false,
                      DataType: "int"
                    },
                    {
                      DataTarget: "PROSCORE",
                      Value: 0,
                      OriginalValue: null,
                      PK: false,
                      DataType: "int"
                    },
                    {
                      DataTarget: "ACTSCORE",
                      Value: 0,
                      OriginalValue: null,
                      PK: false,
                      DataType: "int"
                    },
                    {
                      DataTarget: "ATTACHMENTS",
                      Value: this.fieldToken,
                      OriginalValue: null,
                      PK: false,
                      DataType: "Store.ecidiDoc"
                    },
                    {
                      DataTarget: "INPUTERFULLNAME",
                      Value: this.data.INPUTERFULLNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTERNAME",
                      Value: this.data.INPUTERNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "PHONENUM",
                      Value: this.data.PHONENUM,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTERDEPTNAME",
                      Value: this.data.INPUTERDEPTNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTDATE",
                      Value: this.data.INPUTDATE,
                      OriginalValue: null,
                      PK: false,
                      DataType: "TimeStamp"
                    },
                    {
                      DataTarget: "ISREPLY",
                      Value: this.data.ISREPLY,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    }
                  ],
                  children: []
                }
              ]
            },
            _ATTACHMENT_DELETE_IDS_: "",
            formInfo: {
              GUID: "",
              RESTATE: "1",
              CONSTRUCTPRO: this.data.CONSTRUCTPRO,
              PRODEPT:this.data.PRODEPT,
              SYSPRJID: this.data.SYSPRJID,
              CENTERPOSITION: this.data.CENTERPOSITION,
              CHECKDATE: this.data.CHECKDATE,
              CHECKMONTH: this.data.CHECKMONTH,
              CHECKYEAR: this.data.CHECKYEAR,
              CHECKMY: this.data.CHECKMY,
              FATHERCLASS_TEXT: this.data.FATHERCLASS_TEXT,
              FATHERCLASS: this.data.FATHERCLASS,
              CHECKPRO_TEXT: this.data.CHECKPRO_TEXT,
              CHECKPRO: this.data.CHECKPRO,
              CHECKQUARTER: this.data.CHECKQUARTER,
              CHECKITEMS_TEXT: this.data.CHECKITEMS_TEXT,
              CHECKITEMS: this.data.CHECKITEMS,
              SECURITYLEVEL: "一般",
              CHILDCLASS: this.data.CHILDCLASS,
              IMPORTANCE: this.data.IMPORTANCE,
              WEIGHT: this.data.WEIGHT,
              SYSTODAY: this.data.SYSTODAY,
              DESCRIPTION: this.data.DESCRIPTION,
              HIDDENNUM: "0",
              PROSCORE: "0",
              ACTSCORE: "0",
              ATTACHMENTS: this.fieldToken,
              INPUTERFULLNAME: this.data.INPUTERFULLNAME,
              INPUTERNAME:this.data.INPUTERNAME,
              PHONENUM: this.data.PHONENUM,
              INPUTERDEPTNAME: this.data.INPUTERDEPTNAME,
              INPUTDATE: this.data.INPUTDATE,
              ISREPLY:this.data.ISREPLY
            }
          };
          let json = {
            FixJSON: JSON.stringify(params)
          };
          this.$ajax({
            url: this.COMMON_URL + "?_viewId=PMHSE_INSPECTION",
            method: "post",
            data: json,
            async: false
          }).then(res => {
            console.log("~~~~~~~~~~~~~~~~~~~~~~~~", res);
            if (res.status == 200) {
              this.toastValue = true;
              this.$store.state.SQLiteDB.transaction(
                tx => {
                  tx.executeSql(
                    'DELETE FROM PMHSE_INSPECTION WHERE GUID="' +
                      this.data.GUID +
                      '"'
                  );
                },
                err => {
                  console.log("错误", err);
                }
              );
            }
          });
        
        }
        // this.showPercent = false
        // this.percent = 0
        //  this.$emit('input', this.list)
        // this.show = false
      };
      var fail = error => {
        // 上传失败
        console.log(JSON.stringify(error));
        // //console.log('photoFailed')
        // this.showPercent = false
        // this.percent = 0
        // console.log("上传失败")
      };
      var options = new FileUploadOptions();
      console.log("fileUpload:" + options);
      options.fileKey = "fileName";
      options.fileName = fileURL.substr(
        fileURL.lastIndexOf("/"),
        fileURL.lastIndexOf("?") - fileURL.lastIndexOf("/")
      );
      if (!options.fileName) {
        options.fileName = fileURL.substr(fileURL.lastIndexOf("/"));
      }
      options.mimeType = "application/octet-stream";
      (options.httpMethod = "POST"),
        (options.headers = {
          Accept: "*/*",
          "Accept-Encoding:": "gzip, deflate",
          "Accept-Language": " zh-CN,zh;q=0.9",
          Connection: "keep-alive"
        });
      (options.chunkedMode = false),
        // 如果要传参数，写这里
        (options.params = {
          Filename: fileURL.substr(fileURL.lastIndexOf("/") + 1),
          Upload: "Submit Query"
          // modularName: 'CNL',
          // allowType: 'jpeg;jpg;png;pdf;doc;xls;xlsx;docx',
        });
      var ft = new FileTransfer();
      //注册监听上传进度
      ft.onprogress = progressEvent => {
        if (progressEvent) {
          this.percent = Math.round(
            (progressEvent.loaded * 100) / progressEvent.total
          );
        }
      };
      let params =
        "type=customerDownloadService&FixJSON={%27_method%27:%27streamSupportService.saveTempAttachment%27,%27_param%27:{pageToken:%27" +
        this.pageToken +
        "%27,fieldToken:%27" +
        this.fieldToken +
        "%27,datatype:%27Store.ecidiDoc%27}}";
      if (device.platform == "iOS") {
        // params =
        // "type=customerDownloadService&FixJSON={%27_method%27:%27streamSupportService.saveTempAttachment%27,%27_param%27:{pageToken:%27" +
        // this.pageToken + "%27,fieldToken:%27" + this.fieldToken + "%27,datatype:%27Store.ecidiDoc%27}}"
        params =
          "type=customerDownloadService&FixJSON={'_method':'streamSupportService.saveTempAttachment','_param':{'pageToken':'" +
          this.pageToken +
          "','fieldToken':'" +
          this.fieldToken +
          "',datatype:'Store.ecidiDoc'}}";
      }
      //'type=%27customerDownloadService%27&FixJSON=%7B%27_method%27:%27streamSupportService.saveTempAttachment%27,%27_param%27:%7B%27pageToken%27:%27' +
      //  this.pageToken + '%27,%27fieldToken%27:%27' + this.fieldToken + '%27%7D%7D'

      //上传地址
      let SERVER = "";
      // if (this.belongSubSys != '') {
      SERVER =
        this.COMMON_URL.replace("Action.cmd", "StreamSupportAction.cmd") +
        "?" +
        params;
      // }
      // console.log('开始上传'+SERVER)
      // if (this.server != '') {
      //   SERVER = this.server
      //   params = this.params == '' ? '' : this.params
      // }
      console.log("开始上传" + SERVER);
      if (device.platform == "iOS") {
        SERVER = encodeURI(SERVER);
      }
      console.log("optionoffline", options);
      console.log(fileURL);
      ft.upload(fileURL, SERVER, success, fail, options);
    },
    onSwipeRight() {
      this.$router.push("/offlinehidangerlist");
    },
    backhome() {
      this.$router.push("/offlinehidangerlist");
    },
    //下载附件
    checkFile(fileId, name, size) {
      var url =
        "http://qhsz.simulate.com:8080/qhszpm/servlet/StreamSupportAction.cmd?type=%27customerDownloadService%27&FixJSON=%7B_method%3A%27streamSupportService.getAttachment%27%2C_param%3A%7BattachmentId%3A" +
        fileId +
        "%7D%7D";

      this.$router.push({
        path: "/fileInfo",
        name: "fileInfo",
        params: {
          name: name,
          size: size,
          url: url
        }
      });
    },
    getDetailInfo() {
      this.$store.state.SQLiteDB.transaction(tx => {
        tx.executeSql(
          'SELECT * FROM PMHSE_INSPECTION WHERE GUID ="' + this.GUID + '"',
          [],
          (tx, result) => {
            console.log("详情结果", result);
            this.data = result.rows.item(0);
            this.checkDate = this.data.CHECKDATE.substring(0, 10);
            this.FATHERCLASS = this.data.FATHERCLASS;
            this.CHECKPRO = this.data.CHECKPRO;
            this.CHECKITEMS = this.data.CHECKITEMS;
            this.DESCRIPTION = this.data.DESCRIPTION;
            this.name = this.data.INPUTERFULLNAME;
            this.phone = this.data.PHONENUM;
            this.dept = this.data.INPUTERDEPTNAME;
            this.inputDate = this.data.INPUTDATE;
            this.centerPosition = this.data.CENTERPOSITION;
            this.proDept = this.data.PRODEPT;
            this.isReply = this.data.ISREPLY;
            let res = this.data.FILEURL;
            res = res.replace(/\|\|/g, ".");
            this.offlineUrl = res.split(",");
            console.log("tupianlujing", res);
            console.log("shuzuurl", this.offlineUrl);
          }
        );
      });
    },
    saveInspectionInfo() {
        // Vue.$vux.loading.show({
        //       text : "Loading"
        // })
      this.fieldToken = this.data.ATTACHMENTS;
      if(this.imgList.length == 0){
        var params = {
            _method: "formService.saveFormData",
            requestEventData: {
              eventType: "formSubmitEvent",
              formType: 1,
              bizObjId: "PMHSE_INSPECTION",
              formId: "PMHSE_INSPECTION_ADD",
              buttonId: this.guid()
            },
            _OBJ_NAME_: "PMHSE_INSPECTION",
            _FORM_ID_: "PMHSE_INSPECTION_ADD",
            useType: "add",
            pageToken: this.pageToken,
            formData: {
              objName: "PMHSE_INSPECTION",
              pks: ["GUID"],
              data: [
                {
                  rowData: [
                    {
                      DataTarget: "GUID",
                      Value: "",
                      OriginalValue: null,
                      PK: true,
                      DataType: "String"
                    },
                    {
                      DataTarget: "RESTATE",
                      Value: "0",
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "PRODEPT",
                      Value: this.data.PRODEPT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CONSTRUCTPRO",
                      Value: this.data.CONSTRUCTPRO,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "PROJECTID",
                      Value: this.data.PROJECTID,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SYSPRJID",
                      Value: this.data.SYSPRJID,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CENTERPOSITION",
                      Value: this.data.CENTERPOSITION,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKDATE",
                      Value: this.data.CHECKDATE,
                      OriginalValue: null,
                      PK: false,
                      DataType: "DATE"
                    },
                    {
                      DataTarget: "CHECKMONTH",
                      Value: this.data.CHECKMONTH,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKYEAR",
                      Value: this.data.CHECKYEAR,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKMY",
                      Value: this.data.CHECKMY,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "FATHERCLASS_TEXT",
                      Value: this.data.FATHERCLASS_TEXT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "FATHERCLASS",
                      Value: this.data.FATHERCLASS,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKPRO_TEXT",
                      Value: this.data.CHECKPRO_TEXT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKPRO",
                      Value: this.data.CHECKPRO,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKQUARTER",
                      Value: this.data.CHECKQUARTER,
                      OriginalValue: null,
                      PK: false,
                      DataType: "int"
                    },
                    {
                      DataTarget: "CHECKITEMS_TEXT",
                      Value: this.data.CHECKITEMS_TEXT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHECKITEMS",
                      Value: this.data.CHECKITEMS,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SECURITYLEVEL",
                      Value: "一般",
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "CHILDCLASS",
                      Value: this.data.CHILDCLASS,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "IMPORTANCE",
                      Value: this.data.IMPORTANCE,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "WEIGHT",
                      Value: this.data.WEIGHT,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "SYSTODAY",
                      Value: this.data.SYSTODAY,
                      OriginalValue: null,
                      PK: false,
                      DataType: "TimeStamp"
                    },
                    {
                      DataTarget: "DESCRIPTION",
                      Value: this.data.DESCRIPTION,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "HIDDENNUM",
                      Value: 0,
                      OriginalValue: null,
                      PK: false,
                      DataType: "int"
                    },
                    {
                      DataTarget: "PROSCORE",
                      Value: 0,
                      OriginalValue: null,
                      PK: false,
                      DataType: "int"
                    },
                    {
                      DataTarget: "ACTSCORE",
                      Value: 0,
                      OriginalValue: null,
                      PK: false,
                      DataType: "int"
                    },
                    {
                      DataTarget: "ATTACHMENTS",
                      Value: this.fieldToken,
                      OriginalValue: null,
                      PK: false,
                      DataType: "Store.ecidiDoc"
                    },
                    {
                      DataTarget: "INPUTERFULLNAME",
                      Value: this.data.INPUTERFULLNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTERNAME",
                      Value: this.data.INPUTERNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "PHONENUM",
                      Value: this.data.PHONENUM,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTERDEPTNAME",
                      Value: this.data.INPUTERDEPTNAME,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    },
                    {
                      DataTarget: "INPUTDATE",
                      Value: this.data.INPUTDATE,
                      OriginalValue: null,
                      PK: false,
                      DataType: "TimeStamp"
                    },
                    {
                      DataTarget: "ISREPLY",
                      Value: this.data.ISREPLY,
                      OriginalValue: null,
                      PK: false,
                      DataType: "String"
                    }
                  ],
                  children: []
                }
              ]
            },
            _ATTACHMENT_DELETE_IDS_: "",
            formInfo: {
              GUID: "",
              RESTATE: "1",
              CONSTRUCTPRO: this.data.CONSTRUCTPRO,
              PRODEPT:this.data.PRODEPT,
              SYSPRJID: this.data.SYSPRJID,
              CENTERPOSITION: this.data.CENTERPOSITION,
              CHECKDATE: this.data.CHECKDATE,
              CHECKMONTH: this.data.CHECKMONTH,
              CHECKYEAR: this.data.CHECKYEAR,
              CHECKMY: this.data.CHECKMY,
              FATHERCLASS_TEXT: this.data.FATHERCLASS_TEXT,
              FATHERCLASS: this.data.FATHERCLASS,
              CHECKPRO_TEXT: this.data.CHECKPRO_TEXT,
              CHECKPRO: this.data.CHECKPRO,
              CHECKQUARTER: this.data.CHECKQUARTER,
              CHECKITEMS_TEXT: this.data.CHECKITEMS_TEXT,
              CHECKITEMS: this.data.CHECKITEMS,
              SECURITYLEVEL: "一般",
              CHILDCLASS: this.data.CHILDCLASS,
              IMPORTANCE: this.data.IMPORTANCE,
              WEIGHT: this.data.WEIGHT,
              SYSTODAY: this.data.SYSTODAY,
              DESCRIPTION: this.data.DESCRIPTION,
              HIDDENNUM: "0",
              PROSCORE: "0",
              ACTSCORE: "0",
              ATTACHMENTS: this.fieldToken,
              INPUTERFULLNAME: this.data.INPUTERFULLNAME,
              INPUTERNAME:this.data.INPUTERNAME,
              PHONENUM: this.data.PHONENUM,
              INPUTERDEPTNAME: this.data.INPUTERDEPTNAME,
              INPUTDATE: this.data.INPUTDATE,
              ISREPLY:this.data.ISREPLY
            }
          };
          let json = {
            FixJSON: JSON.stringify(params)
          };
          this.$ajax({
            url: this.COMMON_URL + "?_viewId=PMHSE_INSPECTION",
            method: "post",
            data: json,
            async: false
          }).then(res => {
            console.log("~~~~~~~~~~~~~~~~~~~~~~~~", res);
            if (res.status == 200) {
              this.toastValue = true;
              this.$store.state.SQLiteDB.transaction(
                tx => {
                  tx.executeSql(
                    'DELETE FROM PMHSE_INSPECTION WHERE GUID="' +
                      this.data.GUID +
                      '"'
                  );
                },
                err => {
                  console.log("错误", err);
                }
              );
            }
          });
      }else{
        for (var j = 0; j < this.offlineUrl.length; j++) {
         this.upload(this.offlineUrl[j], this.imgList[j].guid);
        }
      }
          
    }
  },
  mounted() {
    this.getDetailInfo();
    this.pageToken = this.guid();
    var greenIcon = L.icon({
      iconUrl: "../src/assets/img/sign-in.png",
      iconSize: [26, 44], // size of the icon
      iconAnchor: [17, 48] // point of the icon which will correspond to marker's location
      //popupAnchor:  [-3, -76] // point from which the popup should open relative to the iconAnchor
    });
    //获取表单数据信息
    // var params = {
    //   "_method": "formService.getFormData",
    //   "requestEventData": {        "eventType": "formInitEvent",
    //     "formType": 1,
    //     "bizObjId": "PMHSE_INSPECTION",
    //     "formId": "PMHSE_INSPECTION_ADD"      },
    //   "useType": "view",
    //   "getData": {        "useType": "view",
    //     "objName": "PMHSE_INSPECTION",
    //     "relatedObj": ["PMHSE_INSPECTION"],
    //     "pk": [{ "key": "GUID", "value": this.GUID }]      },
    //   "getSysVar": { "SYSTODAY": "{sysDate.Today}", "INPUTERFULLNAME": "{sysLoginUser.userName}", "PHONENUM": "{sysLoginUser.mobil}", "INPUTERDEPTNAME": "{sysLoginUser.orgName}", "INPUTDATE": "{sysDate.Today}" },
    //   "getFormVerify": { "objName": "PMHSE_INSPECTION", "viewId": "PMHSE_INSPECTION_ADD" },
    //   "getToolbar": { "useType": "view", "objName": "PMHSE_INSPECTION", "viewId": "PMHSE_INSPECTION_ADD" }
    // };
    // let json = {
    //   FixJSON: JSON.stringify(params),
    // };
    // this.$ajax({
    //   // async:false,
    //   url: this.COMMON_URL + "?_isBreak=false&objName=PMHSE_INSPECTION&_useType=view&_pk=GUID&_pkValue=" + this.GUID,
    //   method: 'post',
    //   data: json
    // }).then(res => {
    //   //console.log(res);
    //   this.checkDate = res.data.getData.PMHSE_INSPECTION[0].CHECKDATE.val.substring(0, 10);
    //   this.FATHERCLASS = res.data.getData.PMHSE_INSPECTION[0].FATHERCLASS.val;
    //   this.CHECKPRO = res.data.getData.PMHSE_INSPECTION[0].CHECKPRO.val;
    //   this.CHECKITEMS = res.data.getData.PMHSE_INSPECTION[0].CHECKITEMS.val;
    //   this.DESCRIPTION = res.data.getData.PMHSE_INSPECTION[0].DESCRIPTION.val;
    //   this.name = res.data.getData.PMHSE_INSPECTION[0].INPUTERFULLNAME.val;
    //   this.phone = res.data.getData.PMHSE_INSPECTION[0].PHONENUM.val;
    //   this.dept = res.data.getData.PMHSE_INSPECTION[0].INPUTERDEPTNAME.val;
    //   this.inputDate = res.data.getData.PMHSE_INSPECTION[0].INPUTDATE.val.substring(0, 10);
    //   this.centerPosition = res.data.getData.PMHSE_INSPECTION[0].CENTERPOSITION.val;
    //   this.ATTACHMENTS = res.data.getData.PMHSE_INSPECTION[0].ATTACHMENTS.val;
    // });

    //console.log("jkakjhskj"+this.site);
    //绘制地图
    map = L.map("map", {
      center: [22.521671, 113.895794],
      zoom: 13
    });
    L.tileLayer(
      "http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",
      {
        subdomains: ["1", "2", "3", "4"],
        attribution: "高德"
      }
    ).addTo(map);
    //  map.on('click', onMapClick);
    // let th=this;
    // function onMapClick(e) {
    //   if(marker){
    //     map.removeLayer(marker)
    //   }
    //   marker = new L.Marker(e.latlng, {icon: greenIcon}).addTo(map);
    //   map.addLayer(marker);
    //   th.centerPosition=e.latlng;
    //   console.log(th.centerPosition);
    //   }
    console.log(this.site);
    var locate = this.site;
    var long = locate.slice(locate.indexOf("(") + 1, locate.indexOf(","));
    var latitude = locate.slice(locate.indexOf(",") + 2, locate.indexOf(")"));
    if (marker) {
      map.removeLayer(marker);
    }
    marker = new L.Marker([long, latitude], { icon: greenIcon }).addTo(map);
    map.addLayer(marker);
    map.panTo([long, latitude]);
  },
  watch: {}
};
</script>
 
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
/* .transition-view /deep/.weui-cells__title {
      margin-top: 0.77em;
    margin-bottom: 0.3em;
    padding-left: 15px;
    padding-right: 15px;
    color: #353535;
    font-size: 14px;
} */
.transition-view /deep/ .vux-header .vux-header-left .left-arrow:before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(0, 0, 0, 0.8);
  border-width: 1px 0 0 1px;
  -webkit-transform: rotate(315deg);
  transform: rotate(315deg);
  top: 8px;
  left: 7px;
}
.transition-view /deep/ .vux-header .vux-header-title {
  line-height: 40px;
  text-align: center;
  font-size: 18px;
  font-weight: 400;
  color: #333;
}
#map {
  width: 100%;
  height: 25%;
}
.content {
  width: 100%;
  height: 75%;
}
.file {
  display: flex;
  align-items: center;
  position: relative;
  padding-bottom: 16px;
}
.file-icon {
  width: 16px;
  height: 16px;
}
.file-name {
  margin-left: 16px;
  font-size: 12px;
  color: #343434;
}
.file-size {
  font-size: 11px;
  color: #9f9f9f;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
}
.transition-view /deep/ .weui-cells__title {
  color: #333;
}
</style>